<script type="text/javascript" src="<?=base_url()?>resource/plugins/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
    $(function(){
        trbgmoves('#d3dff2');
    })
    function updatebrand(id){
        switch($('#'+id).text()){
            case '<?=lang('smtxg')?>':
                var brandname = $('#brand' + id).text();
                var bdtext = "<input type='text' id='bdtext" + id + "' value='" + brandname + "'" + ">";
                $('#brand' + id).html(bdtext);
                var modelname = $('#model' + id).text();
                var mdtext = "<input type='text' id='mdtext" + id + "' value='" + modelname + "'" + ">";
                $('#model' + id).html(mdtext);
                $('#'+id).text('<?=lang('smtqrxg')?>');
            break;
            case '<?=lang('smtqrxg')?>':
                var brandname=$('#bdtext'+id).val();
                var modelname=$('#mdtext'+id).val();
                $.post("<?=blang_url('ajax/ajax/updatebrand')?>", {'id':id,'bdname':brandname,'mdname':modelname},function(data){
                    var obj = JSON.parse(data);
                    var status=obj.status;
                    switch (status){
                        case '2':
                            alert('<?=lang('smtdqxgxycz')?>');
                            $('#brand' + id).html(brandname);
                            $('#model' + id).html(modelname);
                            $('#'+id).text('<?=lang('smtxg')?>');
                            break;
                        case '1':
                            $('#brand' + id).html(brandname);
                            $('#model' + id).html(modelname);
                            $('#'+id).text('<?=lang('smtxg')?>');
                            alert("<?=lang('smtxgcg')?>！"+obj.count);
                            if(obj.rollnum > 0) {
                                $('#tishis').html("<?=lang('smtpp')?>：" + obj.oldbrand + " <?=lang('smtdymx')?>：" + obj.oldmodel + " <?=lang('smthgsjl')?>" + obj.rollnum + " <a style='color: blue' href='" + "<?=blang_url('orders/Smtexcel/smtzhaobudao')?>" + "#"+obj.ordid+"'> <?=lang('smtdjck')?></a>");
                            }
                            if(obj.newnum > 0){
                                $('#tishis').html($('#tishis').html()+"<?=lang('smtxghpp')?>："+obj.newbrand+" <?=lang('smtdymx')?>："+obj.newmodel+" <?=lang('smtxzsjl')?>"+obj.newnum+" <a style='color: blue' href='" + "<?=blang_url('orders/Smtexcel/smtxxfx')?>" + "/1/"+obj.newmodel+"'> <?=lang('smtdjck')?></a>");
                            }
                            break;
                        case '0':
                            alert('SQL Error：1！！！');
                            break;
                    }
                });
                break;
        }
    }
</script>
<!--top结束-->
<div class="mian">
    <div class="mian1">
        <div class="mian2">
            <!--left start-->
            <?php $this->load->view('defaults/common/left');?>
            <!--left end-->

            <!--right start-->
            <div class="right">
                <!--breadcrumb start-->
                <div class="righta"><?=$this->breadcrumb->generateHTML();?>&nbsp; <span style="color: red" id="tishis"><?=$nums?></span></div>
                <!--breadcrumb end-->

                <!-- contents start -->
                <div id="contents">
                    <div id="ct_search" >
                        <form action="<?=blang_url('orders/Smtexcel/modellist')?>" method="post" name="searchform" >
                            <table id="search_tb">
                                <tr>
                                    <td >
                                        <?=lang('smtpp')?>:<input type="text" id="brand" name="brand">
                                        <?=lang('smtxh')?>：<input type="text" id="model" name="model">
                                        <input type="submit" value="<?=lang('smtcx')?>">
                                    </td>
                                </tr>
                            </table>
                        </form>
                    </div>
                    <div class="ct_content" >
                        <table class="tbwd800" cellspacing="0">
                            <thead class="table_thead" >
                            <tr>
                                <th width="15%" ><?=lang('smtpp')?></th>
                                <th width="10%" ><?=lang('smtxh')?></th>
                                <th width="20%" ><?=lang('smtcz')?></th>
                                <th width="15%" >XXXXX</th>
                                <th width="10%" >XXXXX</th>
                                <th width="10%" >XXXXX</th>
                                <th width="10%" >XXXXX</th>
                                <th width="10%" >XXXXXX</th>
                            </tr>
                            </thead>
                            <?PHP foreach($modellist as $rs):?>
                                <tr class="moves" align="center">
                                    <td width="15%" id="brand<?=$rs['id']?>"><?=$rs['brand']?></td>
                                    <td width="10%" id="model<?=$rs['id']?>"><?=$rs['model']?></td>
                                    <td width="20%">
                                        <a href="javascript:void(0)" id="<?=$rs['id']?>" onclick="updatebrand(id)"><?=lang('smtxg')?></a>
                                        <a href="<?=blang_url('orders/Smtexcel/deletebrand/'.$rs['id'].'/'.$page)?>" onclick="return confirm('Are you sure delete？')"><?=lang('smtsc')?></a>
                                    </td>
                                    <td width="15%"></td>
                                    <td width="10%"></td>
                                    <td width="10%"></td>
                                    <td width="10%"></td>
                                    <td width="10%" align="center"></td>
                                </tr>
                            <?php endforeach;?>
                                <tr><th colspan="8" height="40"><?=$pageshow?></th></tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <!-- contents end -->
            </div>
            <!--right end-->
        </div>
    </div>
</div>

